home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Moscow ML 1.31 / source code / mosml / src / test / testb.sml < prev    next >
Encoding:
Text File  |  1996-07-03  |  740 b   |  30 lines  |  [TEXT/R*ch]

  1. (* Evaluation order *)
  2.  
  3. (let val nil = [1,2] and _ = raise Io "WRONG" in "DEAD" end)
  4. handle Bind => "OK" | _ => "WRONG";
  5. ((fn 0 => "WRONG") 1)
  6. handle Match => "OK" | _ => "WRONG";
  7.  
  8. (map (raise Io "OK") (raise Io "WRONG"))
  9. handle Io x => [x];
  10.  
  11. (raise Io "OK", raise Io "WRONG")
  12. handle Io x => (x, x);
  13.  
  14. {bbb=raise Io "OK", aaa=raise Io "WRONG"}
  15. handle Io x => {aaa=x, bbb=x};
  16.  
  17. fun pr s = (output (std_out, s); s);
  18. fun x7 a b c d e f g = (a, b, c, d, e, f, g);
  19. x7 "1" (pr "2") "3" (pr "4") "5" (pr "6") "7";
  20.  
  21. datatype ('a, 'b) AB = NILab | CONSab of {a: 'a, b: 'b};
  22. CONSab {a=pr "a", b=pr "b"};
  23. CONSab {b=pr "b", a=pr "a"};
  24.  
  25. (* Top-level bindings *)
  26.  
  27. val f = fn x => x;
  28. val f = fn 0 => 1 | x => x * f(x-1);
  29. if f 4 = 12 then "OK" else "WRONG";
  30.